package com.mall.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mall.entity.MallCarousel;
import com.mall.entity.PageBean;
import com.mall.entity.RecommendGood;
import com.mall.mapper.RecommendGoodMapper;
import com.mall.service.RecommendGoodService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecommendGoodServiceImpl implements RecommendGoodService {
    private RecommendGoodMapper recommendGoodMapper;

    @Override
    public PageBean getRecommendGoodList(Integer currentPage, Integer pageSize) {
        // 1.设置分页
        PageHelper.startPage(currentPage,pageSize);
        // 2. 执行查询
        List<RecommendGood> recommendGoodMapperList = recommendGoodMapper.getList();
        Page<RecommendGood> p = (Page<RecommendGood>) recommendGoodMapperList;
        // 3.封装PageBean对象
        PageBean pageBean = new PageBean(p.getTotal(), p.getResult());

        return pageBean;
    }
}
